af_zdo.c File Reference
Methods that implement the CC2530ZNP Application Framework / Zigbee Device Objects (AF/ZDO) interface.
More...
#include "af_zdo.h"
#include "msp430x22x4.h"
#include <stdarg.h>
#include <string.h>
#include "application_configuration.h"
Detailed Description
Methods that implement the CC2530ZNP Application Framework / Zigbee Device Objects (AF/ZDO) interface.
The AF/ZDO interface is a more powerful version of the Simple API and allows you to configure, send, and receive Zigbee data. This file acts as an interface between the user's application and the ZNP physical interface. RFIC interface could be either SPI or UART. Refer to Interface Specification for more information.
- Note:
- For more information, define AF_ZDO_VERBOSE. It is recommended to define this on a per-project basis. In IAR, this can be done in Project Options : C/C++ compiler : Preprocessor In the defined symbols box, add: AF_ZDO_VERBOSE
- See also:
- http://processors.wiki.ti.com/index.php/Tutorial_on_the_Examples and http://e2e.ti.com/support/low_power_rf/default.aspx
- Rev
- 601
- Author
- dsmith
- Date
- 2010-06-16 13:09:21 -0700 (Wed, 16 Jun 2010)
YOU ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
Function Documentation
Configures the ZNP for our application. Sets which profileId, etc. we're using as well as binding information FOR EACH ENDPOINT Using the AF/ZDO interface, you can have more than one endpoint. Recommended not to exceed 10 endpoints.
- Parameters:
-
- Precondition:
- znp was initialized and ZCD_NV_LOGICAL_TYPE has been set (COORDINATOR/ROUTER/END_DEVICE).
- Postcondition:
- znpResult contains the error code, or ZNP_SUCCESS if success.
-
can now use afStartApplication()
- Note:
- this method does not check whether the endpoint being registered has already been registered - it is up to the application to manage that.
- See also:
- applicationConfiguration
| void afRegisterGenericApplication |
( |
|
) |
|
Configures the ZNP for a "generic" application: one endpoint, no binding or fancy stuff. Sets which endpoint, profileId, etc. we're using as well as binding information
- Postcondition:
- znpResult contains the error code, or ZNP_SUCCESS if success.
- See also:
- afRegisterApplication()
| void afSendData |
( |
unsigned char |
destinationEndpoint, |
|
|
unsigned char |
sourceEndpoint, |
|
|
unsigned int |
destinationShortAddress, |
|
|
unsigned int |
clusterId, |
|
|
unsigned char * |
data, |
|
|
unsigned char |
dataLength | |
|
) |
| | |
Sends a message to another device over the Zigbee network using the AF command AF_DATA_REQUEST.
- Parameters:
-
| destinationEndpoint | which endpoint to send this to. |
| sourceEndpoint | which endpoint this message originated from on our device |
| destinationShortAddress | the short address of the destination, or ALL_DEVICES or ALL_ROUTERS_AND_COORDINATORS to broadcast the message. |
| clusterId | which cluster this message is for. User definable. Zigbee supports up to 2^16 clusters. A cluster is typically a particular command, e.g. "turn on lights" or "get temperature". If using a predefined Zigbee Alliance Application Profile then this cluster will follow the Zigbee Cluster Library. |
| data | is the data to send. |
| dataLength | is how many bytes of data to send. Must be less than MAXIMUM_PAYLOAD_LENGTH. |
- Note:
- On a coordinator in a trivial test setup, it takes approximately 10mSec from sending AF_DATA_REQUEST to when we receive AF_DATA_CONFIRM.
-
transactionSequenceNumber is an optional user-definable reference number to match AF_DATA_REQUEST messages with AF_DATA_CONFIRM messages.
-
The ZNP will automatically require an ACK from the next device on the route when sending data. To require an ACK from the final destination, change MAC_ACK to APS_ACK at the expense of increased network traffic.
-
The
radius is the maximum number of hops that this packet can travel through before it will be dropped. Should be set to the maximum number of hops expected in the network.
-
adjust AF_DATA_CONFIRM_INTERVAL_MS and AF_DATA_CONFIRM_TIMEOUT_MS based on network size, number of hops, etc.
- Precondition:
- the application was started successfully
-
there is another device on the network with short address of
destinationShortAddress and that device has successfully started its application.
- Postcondition:
- srsp will contain a AF_DATA_REQUEST_SRSP. We will receive a AF_DATA_REQUEST_SRSP regardless of whether the message was successfully sent or not.
-
we will receive a AF_DATA_CONFIRM if the message was successfully sent.
-
znpResult contains the error code, or ZNP_SUCCESS if success.
| signed int printAfIncomingMsgHeader |
( |
unsigned char * |
srsp |
) |
|
Displays the header information in an AF_INCOMING_MSG.
- Parameters:
-
| srsp | a pointer to the buffer containing the message |
- Returns:
- 0 if success, -1 if not a AF_INCOMING_MSG.
| void printAfIncomingMsgHeaderNames |
( |
|
) |
|
Displays the names that go with the above
| void printZdoNetworkAddressResponse |
( |
unsigned char * |
rsp |
) |
|
| unsigned char* zdoNetworkAddressRequest |
( |
unsigned char * |
ieeeAddress, |
|
|
unsigned char |
requestType, |
|
|
unsigned char |
startIndex | |
|
) |
| | |
Requests a device's Short Address for a given long address.
- Parameters:
-
| ieeeAddress | the long address to locate |
| requestType | must be SINGLE_DEVICE_RESPONSE or INCLUDE_ASSOCIATED_DEVICES. If SINGLE_DEVICE_RESPONSE is selected, then only information about the requested device will be returned. If INCLUDE_ASSOCIATED_DEVICES is selected, then the short addresses of the selected device's children will be returned too. |
| startIndex | If INCLUDE_ASSOCIATED_DEVICES was selected, then there may be too many children to fit in one ZDO_NWK_ADDR_RSP message. So, use startIndex to get the next set of children's short addresses. |
- Note:
- DOES NOT WORK FOR SLEEPING END DEVICES
- Postcondition:
- An ZDO_NWK_ADDR_RSP message will be received, with one or more entries.
- Returns:
- a pointer to the beginning of the payload, or a pointer to indeterminate data if error.
- Postcondition:
- znpResult contains the error code, or ZNP_SUCCESS if success.
| void zdoRequestIeeeAddress |
( |
unsigned int |
shortAddress, |
|
|
unsigned char |
requestType, |
|
|
unsigned char |
startIndex | |
|
) |
| | |
Requests a device's MAC Address (64-bit IEEE Address) given a short address.
- Parameters:
-
| shortAddress | the short address to locate |
| requestType | must be SINGLE_DEVICE_RESPONSE or INCLUDE_ASSOCIATED_DEVICES. If SINGLE_DEVICE_RESPONSE is selected, then only information about the requested device will be returned. If INCLUDE_ASSOCIATED_DEVICES is selected, then the short addresses of the selected device's children will be returned too. |
| startIndex | If INCLUDE_ASSOCIATED_DEVICES was selected, then there may be too many children to fit in one ZDO_IEEE_ADDR_RSP message. So, use startIndex to get the next set of children's short addresses. |
- Postcondition:
- An ZDO_IEEE_ADDR_RSP message will be received, with one or more entries.
-
znpResult contains the error code, or ZNP_SUCCESS if success.
| void zdoStartApplication |
( |
|
) |
|
Starts the Zigbee stack in the ZNP using the settings from a previous afRegisterApplication(). After this start request process completes, the device is ready to send, receive, and route network traffic.
- Note:
- On a coordinator in a trivial test setup, it takes approximately 300mSec between sending START_REQUEST and receiving START_REQUEST_SRSP and then another 200-1000mSec from when we receive START_REQUEST_SRSP to when we receive START_CONFIRM. Set START_CONFIRM_TIMEOUT based on size of your network.
-
ZDO_STARTUP_FROM_APP field StartDelay not used
- Precondition:
- afRegisterApplication() was a success.
- Postcondition:
- znpResult contains the error code, or ZNP_SUCCESS if success.
-
We will see Device Status change to DEV_ROUTER, DEV_ZB_COORD, or DEV_END_DEVICE correspondingly if everything was ok.
Variable Documentation
Incremented for each AF_DATA_REQUEST, wraps around to 0.
This buffer will hold the transmitted messages and received SRSP Payload after sendMessage() was called.